package com.hong.spring.aop.interceptor;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @author: csh
 * @Date: 2020/11/7 10:35
 * @Description:
 */
@Aspect
public class AspectJTest {
    @Pointcut("execution( public * com.hong.spring.aop.bean.TestBean.test(..))")
    public void test(){

    }

    @Before("test()")
    public void beforeTest(){
        System.out.println("beforeTest");
    }

    @After("test()")
    public void afterTest(){
        System.out.println("afterTest");
    }

    @Around("test()")
    public Object aroutTest(ProceedingJoinPoint p){
        System.out.println("beforel");
        Object o = null;
        try {
            o = p.proceed();
        }catch (Exception e){
            e.printStackTrace();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("after1");
        return o;
    }


}
